package com.bawei.auth.controller;

import com.bawei.auth.service.UserLoginService;
import com.bawei.common.core.domain.R;
import com.bawei.common.security.service.TokenService;

import com.bawei.mall.user.domain.CusUser;
import com.bawei.system.domain.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：HaoYunde
 * @Package：com.bawei.auth.controller
 * @Project：mall_cloud
 * @name：UserController
 * @Date：2024/6/27 16:27
 */
@RestController
@RequestMapping("/sso")
public class UserController {
    @Autowired
    private UserLoginService userLoginService;
    @Autowired
    private TokenService tokenService;

    /**
     * c端登录
     * @return
     */
    @GetMapping("/login")
    public R<?> login(@RequestParam("username") String username,@RequestParam("password") String password )
    {
        LoginUser userInfo=userLoginService.login(username,password);
        // 获取登录token
        return R.ok(tokenService.createToken2(userInfo));
    }


    @GetMapping("/info")
    public R<CusUser> info(){
        return userLoginService.info();
    }
}
